package com.lhn.netty.nio;

import java.nio.IntBuffer;

/**
 * buffer demo
 *
 * @author lhn
 * @date 2025/05/25 19:24
 * @since 1.0.0
 **/
public class BasicBuffer {

    public static void main(String[] args) {
        // 创建一个buffer 大小为5
        IntBuffer allocate = IntBuffer.allocate(5);
        for (int i = 0; i < allocate.capacity(); i++) {
            allocate.put(i * 2);
        }
        // 将buffer装换, 读写切换
        allocate.flip();

        while (allocate.hasRemaining()) {
            System.out.println(allocate.get());
        }
    }

}